package com.supconit.kqfx.web.fxzf.search.services.Impl;

import com.supconit.kqfx.web.fxzf.search.daos.VehicleDao;
import com.supconit.kqfx.web.fxzf.search.entities.Vehicle;
import com.supconit.kqfx.web.fxzf.search.services.VehicleService;
import com.supconit.kqfx.web.util.IDGenerator;
import hc.orm.AbstractBasicOrmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by aouo on 2018/4/12.
 */
@Service
public class VehicleServiceImpl extends AbstractBasicOrmService<Vehicle, String> implements VehicleService {


    @Autowired
    private VehicleDao vehicleDao;

    @Override
    public Vehicle getById(String s) {
        return vehicleDao.getById(s);
    }

    @Override
    public void insert(Vehicle vehicle) {
        if(vehicle.getId()==null){
            vehicle.setId(IDGenerator.idGenerator());
        }
        vehicleDao.insert(vehicle);
    }

    @Override
    public void update(Vehicle vehicle) {
        vehicleDao.update(vehicle);
    }

    @Override
    public void delete(Vehicle vehicle) {
        vehicleDao.delete(vehicle);
    }

    @Override
    public int vehicleCount(String plate) {
        return vehicleDao.vehicleCount(plate);
    }
}
